package com.flower8.service.impl;

import com.flower8.dao.HomeDao;
import com.flower8.model.HomeInsurer;
import com.flower8.model.HomeLoan;
import com.flower8.model.HomeWealth;
import com.flower8.service.HomeService;
import com.flower8.utils.PageData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Description: 保险精选service接口实现类
 * @Author: tanglin
 * @Date: 2020/3/27 16:02
 * @Version: 1.0
 */
@Service
public class HomeServiceImpl implements HomeService {

    @Autowired
    private HomeDao homeDao;

    /**
     * 保险精选列表
     * @param pd
     * @return
     * @throws Exception
     */
    @Override
    public List<HomeInsurer> getInsurerList(PageData pd) throws Exception {
        return homeDao.getInsurerList(pd);
    }

    /**
     * 保险精选列表数量
     * @param pd
     * @return
     * @throws Exception
     */
    @Override
    public int getInsurerListCount(PageData pd) throws Exception {
        return homeDao.getInsurerListCount(pd);
    }

    /**
     * 根据id查询
     * @param pd
     * @return
     * @throws Exception
     */
    @Override
    public HomeInsurer getInsurerById(PageData pd) throws Exception {
        return homeDao.getInsurerById(pd);
    }

    /**
     * 更新保险精选接口
     * @param homeInsurer
     * @throws Exception
     */
    @Override
    @Transactional
    public void updateInsurer(HomeInsurer homeInsurer) throws Exception {
        homeDao.updateInsurer(homeInsurer);
    }

    /**
     * 新增保险精选接口
     * @param homeInsurer
     * @throws Exception
     */
    @Override
    @Transactional
    public void addInsurer(HomeInsurer homeInsurer) throws Exception {
        homeDao.addInsurer(homeInsurer);
    }

    /**
     * 删除保险精选
     * @param id
     * @throws Exception
     */
    @Override
    @Transactional
    public void deleteInsurer(long id) throws Exception {
        homeDao.deleteInsurer(id);
    }

    /**
     * 闪电贷款列表
     * @param pd
     * @return
     * @throws Exception
     */
    @Override
    public List<HomeLoan> getLoanList(PageData pd) throws Exception {
        return homeDao.getLoanList(pd);
    }

    /**
     * 闪电贷款列表数量
     *
     * @param pd
     * @return
     * @throws Exception
     */
    @Override
    public int getLoanListCount(PageData pd) throws Exception {
        return homeDao.getLoanListCount(pd);
    }

    /**
     * 根据id查询
     *
     * @param pd
     * @return
     * @throws Exception
     */
    @Override
    public HomeLoan getLoanById(PageData pd) throws Exception {
        return homeDao.getLoanById(pd);
    }

    /**
     * 更新闪电贷款接口
     *
     * @param homeLoan
     * @throws Exception
     */
    @Override
    @Transactional
    public void updateLoan(HomeLoan homeLoan) throws Exception {
        homeDao.updateLoan(homeLoan);
    }

    /**
     * 新增闪电贷款接口
     *
     * @param homeLoan
     * @throws Exception
     */
    @Override
    @Transactional
    public void addLoan(HomeLoan homeLoan) throws Exception {
        homeDao.addLoan(homeLoan);
    }

    /**
     * 删除闪电贷款
     *
     * @param id
     * @throws Exception
     */
    @Override
    @Transactional
    public void deleteLoan(long id) throws Exception {
        homeDao.deleteLoan(id);
    }

    /**
     * 首页理财列表
     *
     * @param pd
     * @return
     * @throws Exception
     */
    @Override
    public List<HomeWealth> getWealthList(PageData pd) throws Exception {
        return homeDao.getWealthList(pd);
    }

    /**
     * 首页理财列表数量
     *
     * @param pd
     * @return
     * @throws Exception
     */
    @Override
    public int getWealthListCount(PageData pd) throws Exception {
        return homeDao.getWealthListCount(pd);
    }

    /**
     * 根据id查询
     *
     * @param pd
     * @return
     * @throws Exception
     */
    @Override
    public HomeWealth getWealthById(PageData pd) throws Exception {
        return homeDao.getWealthById(pd);
    }

    /**
     * 更新首页理财接口
     *
     * @param homeWealth
     * @throws Exception
     */
    @Override
    @Transactional
    public void updateWealth(HomeWealth homeWealth) throws Exception {
        homeDao.updateWealth(homeWealth);
    }

    /**
     * 新增首页理财接口
     *
     * @param homeWealth
     * @throws Exception
     */
    @Override
    @Transactional
    public void addWealth(HomeWealth homeWealth) throws Exception {
        homeDao.addWealth(homeWealth);
    }

    /**
     * 删除首页理财
     *
     * @param id
     * @throws Exception
     */
    @Override
    @Transactional
    public void deleteWealth(long id) throws Exception {
        homeDao.deleteWealth(id);
    }
}
